package com.qf.springboot.web.controller;

import com.github.pagehelper.PageInfo;
import com.qf.springboot.entity.Emp;
import com.qf.springboot.services.EmpServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author: COS
 * @time: 2021/12/1 15:08
 * @description:
 */
@Controller
@RequestMapping("/emp")
public class EmpController {

    @Autowired
    private EmpServices empServices;

    @RequestMapping("/getEmpByPage")
    @ResponseBody
    public PageInfo getEmpByPage(Integer page, Integer limit) {
        return empServices.getAllByPage(page, limit);
    }

    @RequestMapping("/getAll")
    public String getEmpAll(Model model, HttpSession session) {
        List<Emp> all = empServices.getAll();
        model.addAttribute("empList",all);
        return "index";
    }
}
